#pragma once


#include "stdint.h"

#include "sys.h"
#ifndef MEM_ALLOC
#error  "Macro "MEM_ALLOC" is unavailable, please define it as follow"
/* define "MEM_ALLOC" like this, "size" is in byte, and the return value should be the allocate memory's base address */
#define MEM_ALLOC(size)     malloc(size)
#endif
#ifndef MEM_FREE
#error  "Macro "MEM_FREE" is unavailable, please define it as follow"
/* define "MEM_FREE" like this, "ptr" is a base address of the memory to be free */
#define MEM_FREE(ptr)       free(ptr)
#endif

#ifndef MEM_COPY
#error  "Macro "MEM_COPY" is unavailable, please define it as follow"
/* define "MEM_COPY" like this, copy data in the buffer "src" to another buffer "dst" with specific length "size" */
#define MEM_COPY(dst, src, size)       memcpy(dst, src, size)
#endif

typedef struct MessageQueue
{
    /* Put the message pointed to by "msg" into the the message queue */
    int32_t     (*Put)(struct MessageQueue *this, uint8_t *msg);
    /* Retrieve a message from the message queue and saves it to the buffer pointed to by "msg" */
    int32_t     (*Get)(struct MessageQueue *this, uint8_t *msg);
    /* Reset the message queue */
    int32_t     (*Reset)(struct MessageQueue *this);
    /* Delete the message queue */
    int32_t     (*Delete)(struct MessageQueue *this);
    /* Return the maximum number of messages in the message queue */
    uint32_t    (*GetCapacity)(struct MessageQueue *this);
    /* Return the number of queued messages in the message queue */
    uint32_t    (*GetCount)(struct MessageQueue *this);
    /* Return the maximum message size in bytes for the message queue */
    uint32_t    (*GetMsgSize)(struct MessageQueue *this);
    /* Return the number available slots for messages in the message queue */
    uint32_t    (*GetSpace)(struct MessageQueue *this);
    
}MessageQueue, *MessageQueueHandle;


/** @breif  Create and initializes a message queue
  * @param  capacity, the maximum number of messages in the message queue
  * @param  msgSize, 
*/
MessageQueueHandle MessageQueueNew(uint32_t capacity, uint32_t msgSize);




